package com.twittex.view
{
	import com.twittex.TwittexFacade;
	import com.twittex.view.components.ApplicationScreen;
	
	import mx.containers.ViewStack;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	

    public class TwittexMediator extends Mediator
    {
        public static const NAME:String = "ApplicationMediator";


        public function TwittexMediator( viewComponent:ViewStack ) {
            super( NAME, viewComponent );
        }

        override public function listNotificationInterests():Array {
            return [
						TwittexFacade.VIEW_LOGIN_SCREEN,
						TwittexFacade.VIEW_MAIN_SCREEN
					];
        }

        override public function handleNotification( note:INotification ):void {
            switch ( note.getName() ) {
				case TwittexFacade.VIEW_LOGIN_SCREEN:
					app.selectedChild = app.loginScreen;
					facade.registerMediator( new LoginScreenMediator( app.loginScreen ) );
					break;

				case TwittexFacade.VIEW_MAIN_SCREEN:
					app.selectedChild = app.mainScreen;
					facade.registerMediator( new MainScreenMediator( app.mainScreen ) );
					break;
            }
        }

        protected function get app():ApplicationScreen {
            return viewComponent as ApplicationScreen
        }
    }
}